<?php 
	class Task_types extends CI_Model{

		function __construct(){
			parent::__construct();
		}

		function get_task_category_list($limit = 0, $offset = 10, $conditions = array()){
			$where = " WHERE status = 1";
			if(!empty($conditions['type'])){
				$where .= " AND type IN({$conditions['type']})";
			}
			if(isset($conditions['pid'])){
				$where .= " AND pid IN({$conditions['pid']})";
			}
			$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM {$this->db->dbprefix}task_types $where ORDER BY sort DESC";
			if($limit > 0 || $offset > 0){
				$sql .= " LIMIT $limit, $offset";
			}
			$result = $this->db->query($sql)->result_array();
			$row_num =  $this->db->query('SELECT FOUND_ROWS() as row_num;')->row_array();
			return array("count" => $row_num['row_num'], "list" => $result);
		}
	}